package com.sjb.sixteen_journey_backend.utils.ws;

import com.alibaba.fastjson.JSONObject;
import com.fasterxml.jackson.databind.ObjectMapper;

public class JSONUtil {
    private static final ObjectMapper objectMapper = new ObjectMapper();

    public static boolean isTypeJSONObject(String message) {
        try {
            new JSONObject(Boolean.parseBoolean(message));
            return true;
        } catch (Exception e) {
            return false;
        }
    }
    public static <T> T toBean(String json, Class<T> clazz) {
        try {
            return objectMapper.readValue(json, clazz);
        } catch (Exception e) {
            throw new RuntimeException("JSON转换失败", e);
        }
    }
}
